
class Item:

    def to_string(self):
        pass

class LineTextItem(Item):

    def __init__(self , value , dot = True):
        self.value = value
        self.dot = dot


    def set_dot(self , b):
        self.dot = b

    def to_string(self):
        text = ''
        if self.dot:
            text = text + '- '
        text += self.value + '\n'
        return text

class EmptyItem(Item):

    def to_string(self):
        return '\n\n'


class KeyValueItem(Item):

    def __init__(self , key , value , dot = True):
        self.key = key
        self.value = value
        self.dot = dot

    def set_dot(self , b):
        self.dot = b

    def to_string(self):
        text = ''
        if self.dot:
            text += '- '
        text += '**' + str(self.key) + '** : ' + str(self.value) + '\n'
        return text

class SubMsgItem(Item):

    def __init__(self):
        self.title = ''
        self.items = []
        self.dot = True

    def set_title(self , title):
        self.title = title

    def add_item(self , item: Item):
        self.items.append(item)

    def set_dot(self , b):
        self.dot = True

    def to_string(self):
        text = ''
        if self.dot:
            text += '- '
        text = self.title + '\n'
        for index , value in enumerate(self.items):
            text += str(index + 1) + '. '  + value.to_string()
        return text



class Message:

    def __init__(self):
        self.title = ''
        self.items = []


    def set_title(self , txt):
        self.title = txt

    def add_item(self , item: Item):
        self.items.append(item)



    def toMarkdownMessage(self):
        text = '# ' + self.title + '\n'

        for item in self.items:
            if item is not None:
                text = text + item.to_string()


        return text

